import Vue from 'vue';
import Router from 'vue-router';
import CampusBinhai from '../components/CampusBinhai.vue';
import CampusChashan from '../components/CampusChashan.vue';
import CampusYueqing from '../components/CampusYueqing.vue';
import LoginFrom from '../components/LoginFrom.vue';
import StudentSystem from '../components/StudentSystem.vue';

Vue.use(Router);

const router = new Router({
  routes: [
    {
      path: '/',
      name: 'CampusBinhai',
      component: CampusBinhai
    },
    {
      path: '/chashan',
      name: 'CampusChashan',
      component: CampusChashan
    },
    {
      path: '/yueqing',
      name: 'CampusYueqing',
      component: CampusYueqing
    },
    {
      path: '/login',
      name: 'LoginFrom',
      component: LoginFrom
    },
    {
      path: '/student-system',
      name: 'StudentSystem',
      component: StudentSystem
    }
  ]
});

router.beforeEach((to, from, next) => {
  if (to.name === 'StudentSystem') {
    next('/login');
  } else {
    next();
  }
});

export default router;